<!-- eslint-disable vue/no-mutating-props -->
<template>
  <a-form-item :label="props.itemData.label">
    <a-input
      v-if="props.itemData.type == 'text'"
      placeholder="请输入"
      allow-clear
      v-model:value.string="dataValue"
      @blur="inputUpdateValue"
    />
    <a-select
      v-if="props.itemData.type == 'select'"
      allow-clear
      placeholder="请选择"
      v-model:value.string="dataValue"
      @change="updateValue"
    >
      <a-select-option
        v-for="i in props.itemData.options"
        :key="'' + i.key"
        :value="'' + i.key"
      >
        {{ i.label }}
      </a-select-option>
    </a-select>
    <a-date-picker
      v-if="props.itemData.type === 'daterange'"
      show-time
      placeholder="请选择日期"
      v-model:value="dataValue"
      @ok:value="dateUpdateValue"
    />
    <!-- daterange -->
  </a-form-item>
</template>

<script setup>
  const props = defineProps({
    itemData: Object,
    dataValue: String
  });
  const emit = defineEmits(['update:value', 'blur']);
  /*  */
  const inputUpdateValue = () => {
    emit('update:value', props.dataValue.toString());
  };
  /* select选择框诗句改变事件 */
  const updateValue = () => {
    emit('update:value', props.dataValue.toString());
  };
  const dateUpdateValue = () => {
    emit('update:value', props.dataValue);
  };
</script>
